<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script
  src="https://code.jquery.com/jquery-3.7.1.js"
  integrity="sha256-eKhayi8LEQwp4NKxN+CfCh+3qOVUtJn3QNZ0TciWLP4="
  crossorigin="anonymous"></script>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .content{
                width: 100%;
                height: 500px;
                background-color: antiquewhite;
                position: relative;
                
        }
        p{
            position: absolute;
            white-space: nowrap;
        }
    </style>
</head>
<body>
    <div class="content">
      

    </div>
    <div><input type="text"><button>发射</button></div>
    <script>
        document.querySelector('button')
        $('button').click(()=>{
            let left = $('.content').width()
            let p = $(`<p style="left:${left}px;t
            op:${setredom(300,0)}px;color:rgb(${setredom(255,0)},${setredom(255,0)},${setredom(255,0)})">${$('input').val()}</p>`)
            $('.content').append(p)
            setInterval(()=>{
                left--
                p.css('left',left)
            },10)
        })
      

        // 生成随机数
        function setredom(max,min) {

            return Math.floor(Math.random()*(max-min)+min)
            
        }

        console.log(setredom(255,0));
        

    </script>
</body>
</html>